package controller;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import sql.FinanceAccountLookUp;
import bean.*;

public class AccountInformation extends HttpServlet
{
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	{
		HttpSession session = request.getSession(true);				
		FinanceAccountLookUp financeInfoLookUp = new FinanceAccountLookUp();
		String address = "";
		
		try 
		{
			FinanceAccountBean finance = new FinanceAccountBean();
			CustomerBean customer = (CustomerBean) session
					.getAttribute("customer");
			finance = financeInfoLookUp.getCustomerFinanceAccount(customer
					.getCustomerId());
			session.setAttribute("financeAccount", finance);
			
			address = "/WEB-INF/account.jsp";
			RequestDispatcher dispatcher = request.getRequestDispatcher(address);
			dispatcher.forward(request, response);
			
		} catch (ServletException e) { e.printStackTrace();
		} catch (IOException e) { e.printStackTrace();
		} catch (ClassNotFoundException e) {e.printStackTrace();
		} catch (SQLException e) {e.printStackTrace();
		}
	}

}
